package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteCartService;
import com.ruoyi.system.api.RemoteShopService;

import com.ruoyi.system.api.domain.Shop;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 店铺服务降级处理
 */
@Component
public class RemoteShopFallbackFactory implements FallbackFactory<RemoteShopService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteShopFallbackFactory.class);

    @Override
    public RemoteShopService create(Throwable throwable) {
        log.error("店铺服务调用失败:{}", throwable.getMessage());
        return new RemoteShopService() {
            @Override
            public R<Shop> getByShopsId(Long shopId, String source) {
                return R.fail("获取店铺失败:" + throwable.getMessage());
            }
        };
    }
}
